package edu.hawaii.senin.iclouds.statistics;

import org.apache.commons.math.util.MathUtils;

/**
 * Implements Poisson distribution.
 * 
 * @author Administrator.
 * 
 */
public class PoissonD {

  /**
   * lambda parameter.
   */
  private Double lambda;

  /**
   * PoissonD constructor.
   * 
   * @param l lambda parameter for Poisson distribution.
   */
  public PoissonD(Double l) {
    this.lambda = l;
  }

  /**
   * Sets the new lambda.
   * 
   * @param l new lambda value.
   */
  public void setLambda(Double l) {
    this.lambda = l;
  }

  /**
   * Returns the lambda value.
   * 
   * @return lambda value.
   */
  public Double getLambda() {
    return this.lambda;
  }

  /**
   * Computes probability for certain k.
   * 
   * @param k for wich it will be computed.
   * @return the probability value.
   */
  public Double getValue(Integer k) {
    return (Math.exp(-this.lambda) * Math.pow(this.lambda, k)) / MathUtils.factorial(k);
  }

}
